package com.liqi.web.controller.items;

import com.liqi.common.annotation.Log;
import com.liqi.common.core.controller.BaseController;
import com.liqi.common.core.domain.AjaxResult;
import com.liqi.common.core.page.TableDataInfo;
import com.liqi.common.enums.BusinessType;
import com.liqi.common.utils.poi.ExcelUtil;
import com.liqi.items.domain.TRelServiceSubject;
import com.liqi.items.service.ITRelServiceSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 主题事项关联Controller
 *
 * @author xiaoli
 * @date 2022-04-08
 */
@RestController
@RequestMapping("/item/serviceSubject")
public class TRelServiceSubjectController extends BaseController
{
    @Autowired
    private ITRelServiceSubjectService tRelServiceSubjectService;

    /**
     * 查询主题事项关联列表
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRelServiceSubject tRelServiceSubject)
    {
        startPage();
        List<TRelServiceSubject> list = tRelServiceSubjectService.selectTRelServiceSubjectList(tRelServiceSubject);
        return getDataTable(list);
    }

    /**
     * 导出主题事项关联列表
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:export')")
    @Log(title = "主题事项关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRelServiceSubject tRelServiceSubject)
    {
        List<TRelServiceSubject> list = tRelServiceSubjectService.selectTRelServiceSubjectList(tRelServiceSubject);
        ExcelUtil<TRelServiceSubject> util = new ExcelUtil<TRelServiceSubject>(TRelServiceSubject.class);
        util.exportExcel(response, list, "主题事项关联数据");
    }

    /**
     * 获取主题事项关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tRelServiceSubjectService.selectTRelServiceSubjectById(id));
    }

    /**
     * 新增主题事项关联
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:add')")
    @Log(title = "主题事项关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRelServiceSubject tRelServiceSubject)
    {
        return toAjax(tRelServiceSubjectService.insertTRelServiceSubject(tRelServiceSubject));
    }

    /**
     * 修改主题事项关联
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:edit')")
    @Log(title = "主题事项关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRelServiceSubject tRelServiceSubject)
    {
        return toAjax(tRelServiceSubjectService.updateTRelServiceSubject(tRelServiceSubject));
    }

    /**
     * 删除主题事项关联
     */
    @PreAuthorize("@ss.hasPermi('item:serviceSubject:remove')")
    @Log(title = "主题事项关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRelServiceSubjectService.deleteTRelServiceSubjectByIds(ids));
    }
}
